<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="/WEB-INF/faces/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <p:panel id="table">
            <h:form id="dispForm">
                <p:dataTable var="teacher" value="#{adminTeacherModelBean.teachers}" id="teachers">
                    <f:facet name="header">
                        Teachers
                    </f:facet>
                    <p:column>
                        <f:facet name="header">
                            Username
                        </f:facet>
                        <h:inputHidden id="tblPid" value="#{teacher.id}" />
                        <h:outputText value="#{teacher.user.login}" id="user" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Password
                        </f:facet>
                        <h:outputText value="#{teacher.user.password}" id="pass" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Name
                        </f:facet>
                        <h:outputText value="#{teacher.user.fname}" id="name" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Email
                        </f:facet>
                        <h:outputText value="#{teacher.user.email}" id="email"/>
                    </p:column>
                    <p:column>
                        <p:commandButton value="Delete" actionListener="#{adminTeacherControllerBean.delete}" update="@form">
                            <f:attribute value="#{teacher}" name="teacher" />
                        </p:commandButton>
                    </p:column>
                    <p:column>
                        <input type="button" value="Edit" class="editBtn" />
                    </p:column>
                </p:dataTable>
            </h:form>
        </p:panel>
        <h:form>
            <h:inputHidden id="pkey" value="#{adminTeacherModelBean.editId}" />
            <h:panelGrid columns="2">
                <h:outputLabel for="formuser" value="Username: "/>
                <p:inputText id="formuser" value="#{adminTeacherModelBean.newUser.login}" required="true"/>
                <h:outputLabel for="formpass" value="Password: " />
                <p:inputText id="formpass" value="#{adminTeacherModelBean.newUser.password}" required="true"/>
                <h:outputLabel for="formname" value="Name: "/>
                <p:inputText id="formname" value="#{adminTeacherModelBean.newUser.fname}" required="true"/>
                <h:outputLabel for="formemail" value="Email: " />
                <p:inputText id="formemail" value="#{adminTeacherModelBean.newUser.email}" required="true"/>
                <p:commandButton value="Add" actionListener="#{adminTeacherControllerBean.change}" update="table, @form" id="subBtn" />
                <p:messages />
            </h:panelGrid>
        </h:form>
    </ui:define>

</ui:composition>
